<?php
/**
 * Created by PhpStorm.
 * User: wx
 * Date: 2018/7/19
 * Time: 15:20
 */

namespace Modules\Admin\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Modules\Admin\Service\TmeplateService;
class TemplateController extends Controller
{
    /**
     * 加载模板内容
     * @param TmeplateService $templateService
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index(TmeplateService $templateService){
     //获取当前所有模板的所有文件夹内容
       $templates=$templateService->getAllTemplate();
       //dd($templates);
     return  view('admin::template.index',compact('templates'));
    }

    /**
     * 设置默认模板
     */
    public function setDefaultTemplate($name){
        //引入后盾网插件
        \HDModule::saveConfig(['template' => $name], 'config');
        //设置闪存，并返回
        session()->flash('success','设置默认成功！');
        return back();
    }
}